<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>${SYSTEM_NAME}</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/layuiadmin/layui/css/layui.css?v=${FILE_VERSION}" media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/static/layuiadmin/style/admin.css?v=${FILE_VERSION}" media="all">
</head>
<body>
	<div class="layui-fluid">
       	<div class="layui-card">
         	<div class="layui-card-header">系统通知</div>
         	<div class="layui-card-body">
         		<div class="layui-form layer-query">
					<div class="layui-form-item">
						<div class="layui-inline">
							<label class="layui-form-label" style="width: 120px">公告类型：</label>
							<div class="layui-input-inline">
								<select id="type">
									<option selected="selected" value="">选择公告类型</option>
									<c:forEach items="${noticeTypeMap}" var="t">
										<option value="${t.key }">${t.value }</option>
									</c:forEach>
								</select>
							</div>
						</div>
						<div class="layui-inline">
							<label class="layui-form-label">标题：</label>
							<div class="layui-input-inline">
								<input type="text" id="title" placeholder="请输入标题" class="layui-input">
							</div>
						</div>
						<div class="layui-inline">
							<button class="layui-btn layui-btn-primary layui-border-blue" onclick="reload()">查询</button>
						</div>
					</div>
				</div>
         		<hr class="layui-bg-green">
           		<table class="layui-table" lay-filter="tableList" id="layerTable">
				</table>
         	</div>
       	</div>
  	</div>

	<script type="text/html" id="toolbar">
		<div class="layui-btn-container">
			<button class="layui-btn layui-btn-primary layui-border-blue" onclick="addLayer('/sys/notice/add/input');">新增</button>
			<button class="layui-btn layui-btn-primary layui-border-blue" onclick="modi('/sys/notice/edit/input');">编辑</button>
			<button class="layui-btn layui-btn-primary layui-border-red" onclick="deleteBatch('/sys/notice/del/deleteByIds');">删除</button>
		</div>
	</script>

	<script type="text/html" id="barTpl">
		<a class="layui-btn layui-btn-primary layui-border-blue layui-btn-xs" lay-event="edit">编辑</a>
		<a class="layui-btn layui-btn-primary layui-border-red layui-btn-xs" lay-event="del">删除</a>
	</script>

	<script type="text/html" id="dateTpl">
		{{  new Date(d.dateCreate).format("yyyy-MM-dd hh:mm:ss") }}
	</script>
	<script src="${pageContext.request.contextPath}/static/js/common-2.0.0.js?v=${FILE_VERSION}"></script>
  	<script src="${pageContext.request.contextPath}/static/layuiadmin/layui/layui.js?v=${FILE_VERSION}"></script>
  	<script src="${pageContext.request.contextPath}/static/js/jquery-3.3.1.min.js?v=${FILE_VERSION}"></script>
	<script src="${pageContext.request.contextPath}/static/js/common/core-2.0.0.js?v=${FILE_VERSION}"></script>
  	<script>
  		var table;
	  	layui.config({
	  		base: getContextPath() + '/static/layuiadmin/' //静态资源所在路径
	  	}).extend({
	    	index: 'lib/index' //主入口模块
	  	}).use(['table', 'element'], function() {
			var element = layui.element;
			table = layui.table;
			table.render({ 
				elem : '#layerTable',
				even : "true",
				toolbar: '#toolbar',
				defaultToolbar: ['filter', 'exports', 'print'],
				limit: 10,
				limits: [10,30,50,100],
				id : 'tableList',
				url : getContextPath() + '/sys/notice/list/listInfo',
				page : true,
				method : 'post',
				cols : [[
					{checkbox : true,fixed : true}
					,{field : 'typeName',width : 140,title : "公告类型"}
					,{field : 'title',minWidth : 200,title : "标题"}
					,{field : 'content',minWidth : 200,title : "通知内容"}
					,{field : 'isShowName',width : 100,title : "是否显示"}
					,{field : 'dateCreate',width : 180,title : "发布时间",templet : '#dateTpl'}
					,{fixed: 'right', width:240, align:'center',title:"操作", toolbar: '#barTpl'}
				]],
				request : {
					pageName : 'current', //页码的参数名称，默认：page
					limitName : 'size' //每页数据量的参数名，默认：limit
				}
			//如果无需自定义请求参数，可不加该参数
			});

			//监听工具条
			table.on('tool(tableList)', function(obj) {
				var data = obj.data;
				if (obj.event === 'del') {
					deleteById(data,obj,'/sys/notice/del/deleteById');
				} else if (obj.event === 'edit') {
					addLayer('/sys/notice/edit/input', data.id);
				}
			});
		});
	  	

		function reload() {
			table.reload('tableList', {
				where : {
					"title" : $("#title").val(),
					"type" : $("#type").val()
				}
			});
		}

  	</script>
</body>
</html>
